<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:body>
        <ui:composition template="./../template/main.xhtml">
            <ui:define name="content">
                 <h1 class="title ui-widget-header ui-corner-all ">Thêm Sản Phẩm</h1>
                <p:messages id="messages" autoUpdate="true" closable="true" showDetail="true"/>
                <!-- Insert -->
                <h:form id="insertForm">
                    <h:panelGrid columns="2" styleClass="my-panel-grid">
                        <h:outputLabel for="name" value="Tên:"/>
                        <p:inputText id="name" value="#{phoneController.selectedPhone.name}" style="width: 200px; margin: 5px" required="true"/>
                        
                        <h:outputLabel for="category" value="Loại:"/>
                        <p:selectOneMenu id="category" value="#{phoneController.selectedPhone.category.id}" style="margin: 5px">
                            <f:selectItems value="#{phoneController.categoryList}" var="categoryList"
                                           itemValue="#{categoryList.id}" itemLabel="#{categoryList.name}"/>
                        </p:selectOneMenu> 

                        <h:outputLabel for="manufacturer" value="Nhà sản xuất:"/>
                        <p:selectOneMenu id="manufacturer" value="#{phoneController.selectedPhone.manufacturer.id}" style="margin: 5px" >
                            <f:selectItems value="#{phoneController.manufacturerList}" var="manufacturerList"
                                           itemValue="#{manufacturerList.id}" itemLabel="#{manufacturerList.name}"/>
                        </p:selectOneMenu>
                        
                        <h:outputLabel for="os" value="Hệ điều hành:"/>
                        <p:selectOneMenu id="os" value="#{phoneController.selectedPhone.os.id}" style="margin: 5px">
                            <f:selectItems value="#{phoneController.osList}" var="osList"
                                           itemValue="#{osList.id}" itemLabel="#{osList.name}"/>
                        </p:selectOneMenu>
                        
                        <h:outputLabel for="price" value="Giá:" />
                        <p:spinner id="price" value="#{phoneController.selectedPhone.price}" required="true" min="50000" stepFactor="50000" style="margin: 5px" >
                            <f:convertNumber integerOnly="true" type="number"/>
                        </p:spinner>
                        
                        <h:outputLabel for="warranty" value="Bảo hành:"/>
                        <p:inputText id="warranty" value="#{phoneController.selectedPhone.warranty}" style="margin: 5px" required="true"/>
                        
                        <h:outputLabel for="specialInfo" value="Ưu điểm:"/>
                        <p:editor id="specialInfo" value="#{phoneController.selectedPhone.advantage}" width="700" height="200" style="margin: 5px" required="true"/>

                        <h:outputLabel for="generalInfo" value="Nhược điểm:"/>
                        <p:editor id="generalInfo" value="#{phoneController.selectedPhone.disadvantage}" width="700" height="200" style="margin: 5px" required="true"/>

                        <h:outputLabel for="standardKit" value="Phụ kiện đi kèm:"/>
                        <p:editor id="standardKit" value="#{phoneController.selectedPhone.standardkit}" width="700" height="200" style="margin: 5px" required="true"/>
                        
                        <h:outputLabel for="description" value="Mô tả:"/>
                        <p:editor id="description" value="#{phoneController.selectedPhone.description}" width="700" height="200" style="margin: 5px" required="true"/>
                     </h:panelGrid>
<!--                    <p:commandButton id="btnInsertTS" update=":InsertTSForm" oncomplete="PF('updateDialog').show()" icon="ui-icon ui-icon-wrench" title="Thêm Đặt tả kĩ thuật">             
                    </p:commandButton>-->
                    
                    <p:commandButton id="btnInsert" action="#{phoneController.insert()}" update=":insertForm, :messages" icon="icon-create" title="Thêm" value="Thêm"/>
                </h:form>
                
                
            </ui:define>
        </ui:composition>
    </h:body>
</html>